<?php


namespace app\api\controller\v1;


use app\api\controller\BaseController;
use app\api\service\UserPhoneService;
use app\api\validate\ThirdLoginValidate;
use app\api\validate\UserCheck;
use app\api\validate\UserRegisterValidate;
use app\lib\exception\HttpException;
use think\App;
use think\facade\Request;

class User extends BaseController
{
    public function __construct()
    {
        if(!Request::isPost()){
            throw new HttpException();
        }
    }

    # 撞库(有信钱包)
    public function check()
    {
        $post = (new UserCheck()) ->goCheck();
        $service = new UserPhoneService();
        $re = $service->user_check($post['phoneNo'], $post['registerFrom']);
        return json($re);
    }

    # 注册(有信钱包)
    public function register()
    {
        $post = (new UserRegisterValidate())->goCheck();
        $service = new UserPhoneService();
        $re = $service->user_register($post['phoneNo'], $post['registerFrom']);
        return json($re);
    }

    # 撞库（信用管家）
    public function third_login()
    {
        $post = (new ThirdLoginValidate()) -> goCheck();
        $service = new UserPhoneService();
        $re = $service->xinyong_third_login($post);
        return json($re);
    }
}